package com.huaxin.hxenum.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import com.huaxin.hxenum.base.BaseCodeEnum;
import com.huaxin.hxenum.base.Describable;

/**
 * 通风类型枚举
 */
public enum VentilationType implements BaseCodeEnum<String>, Describable {

    NATURAL("natural", "自然通风", "依靠门窗自然对流"),
    MECHANICAL("mechanical", "机械通风", "使用风机等设备强制通风"),
    HYBRID("hybrid", "混合通风", "自然与机械结合通风"),
    AIR_CONDITIONING("air_conditioning", "空调通风", "通过中央空调系统换气");

    @EnumValue
    private final String code;
    private final String displayName;
    private final String description;

    VentilationType(String code, String displayName, String description) {
        this.code = code;
        this.displayName = displayName;
        this.description = description;
    }

    @JsonValue
    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDisplayName() {
        return displayName;
    }

    @Override
    public String getDescription() {
        return description;
    }

    public static VentilationType of(String code) {
        for (VentilationType status : VentilationType.values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        return null;
    }

    public static boolean isValid(String code) {
        for (VentilationType status : VentilationType.values()) {
            if (status.getCode().equals(code)) {
                return true;
            }
        }
        return false;
    }
}
